<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php 2009-08-18 08:41:22Z Bleakwind $
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
+-----------------------------------------------------------------------------+
*/

if (!defined( 'ENTRY_INDEX')){
    echo "<h1>Forbidden</h1><p>You don't have permission to access on this server.</p>";
    exit;
}

if (!preg_match("/^[0-9]+$/",$sys->get['mid'])){
    $sys->prompt("failed",$LANGUAGE['s']['member_view']['mid_error']."<!-- mid_error -->");
}else{

    $sql = "SELECT m.*, md.*, mg.*, 
                topic.id as topic_id, topic.subject as topic_subject, topic.post_time as topic_post_time, 
                post.id as post_id, post.post_time as post_post_time
            FROM ".DB_TABLE_MEMBER." m
            LEFT JOIN ".DB_TABLE_MEMBER_DETAIL." md ON md.mid=m.id
            LEFT JOIN ".DB_TABLE_MEMBER_GROUP." mg ON mg.mg_type=m.mg_type
                AND (mg.mg_point_begin<=m.point || mg.mg_point_begin IS NULL)
                AND (mg.mg_point_end>=m.point || mg.mg_point_end IS NULL)
            LEFT JOIN ".DB_TABLE_POST." post ON post.id=md.last_post
            LEFT JOIN ".DB_TABLE_TOPIC." topic ON topic.id=post.topic_id
            WHERE m.id=".$sys->get['mid']."
            GROUP BY m.id";
    $result = &$db->Execute($sql);
    if (!$result) {
        echo $db->ErrorMsg();
    } else {
        if (!$result->EOF) {
            $member_info = array(
                'id'                            => $result->fields['id'],
                'username'                      => $result->fields['username'],
                'email'                         => $result->fields['email'],
                'card'                          => $result->fields['card'],
                'password'                      => $result->fields['password'],
                'question_type'                 => $result->fields['question_type'],
                'question'                      => $result->fields['question'],
                'answer'                        => $result->fields['answer'],
                'mg_type'                       => $result->fields['mg_type'],
                'mg_type_expired'               => $result->fields['mg_type_expired'],
                'silver'                        => $result->fields['silver'],
                'point'                         => $result->fields['point'],
                'bonus'                         => $result->fields['bonus'],
                'pile1'                         => $result->fields['pile1'],
                'pile2'                         => $result->fields['pile2'],
                'pile3'                         => $result->fields['pile3'],
                'pile4'                         => $result->fields['pile4'],
                'pile5'                         => $result->fields['pile5'],
                'pile6'                         => $result->fields['pile6'],
                'active_id'                     => $result->fields['active_id'],
                'if_active'                     => $result->fields['if_active'],
                'if_enable'                     => $result->fields['if_enable'],
                'if_email'                      => $result->fields['if_email'],
                'ip_active'                     => $result->fields['ip_active'],
                'ip_created'                    => $result->fields['ip_created'],
                'ip_change'                     => $result->fields['ip_change'],
                'ip_lastvisit'                  => $result->fields['ip_lastvisit'],
                'time_active'                   => $result->fields['time_active'],
                'time_created'                  => $result->fields['time_created'],
                'time_change'                   => $result->fields['time_change'],
                'time_lastvisit'                => $result->fields['time_lastvisit'],
                'cumulant_silver'               => $result->fields['cumulant_silver'],
                'cumulant_offer'                => $result->fields['cumulant_offer'],
                'cumulant_online'               => $result->fields['cumulant_online'],

                'md_mid'                        => $result->fields['mid'],
                'md_realname'                   => $result->fields['realname'],
                'md_gender'                     => $result->fields['gender'],
                'md_birthday'                   => $result->fields['birthday'],
                'md_address'                    => $result->fields['address'],
                'md_postalcode'                 => $result->fields['postalcode'],
                'md_telephone'                  => $result->fields['telephone'],
                'md_mobile'                     => $result->fields['mobile'],
                'md_avatar_type'                => $result->fields['avatar_type'],
                'md_avatar_value'               => $result->fields['avatar_value'],
                'md_website'                    => $result->fields['website'],
                'md_gtalk'                      => $result->fields['gtalk'],
                'md_msn'                        => $result->fields['msn'],
                'md_icq'                        => $result->fields['icq'],
                'md_qq'                         => $result->fields['qq'],
                'md_yahoo'                      => $result->fields['yahoo'],
                'md_bio'                        => $result->fields['bio'],
                'md_sign'                       => $result->fields['sign'],
                'md_last_post'                  => $result->fields['last_post'],
                'md_total_topic'                => $result->fields['total_topic'],
                'md_total_reply'                => $result->fields['total_reply'],
                'md_total_elite'                => $result->fields['total_elite'],
                'md_remark'                     => $result->fields['remark'],

                'mg_id'                         => $result->fields['mg_id'],
                'mg_type'                       => $result->fields['mg_type'],
                'mg_point_begin'                => $result->fields['mg_point_begin'],
                'mg_point_end'                  => $result->fields['mg_point_end'],
                'mg_ag_id'                      => $result->fields['mg_ag_id'],
                'mg_name'                       => $result->fields['mg_name'],
                'mg_brief'                      => $result->fields['mg_brief'],
                'mg_icon'                       => $result->fields['mg_icon'],
                'mg_privilege'                  => unserialize($result->fields['mg_privilege']),
                'mg_fileallow'                  => unserialize($result->fields['mg_fileallow']),
                'mg_if_enable'                  => $result->fields['mg_if_enable'],
                'mg_rank'                       => $result->fields['mg_rank'],

                'topic_id'                      => $result->fields['topic_id'],
                'topic_subject'                 => $result->fields['topic_subject'],
                'topic_post_time'               => $result->fields['topic_post_time'],
                'post_id'                       => $result->fields['post_id'],
                'post_post_time'                => $result->fields['post_post_time'],
            );
            if ($member_info['mg_type_expired'] > 0) {
                if ($sys->check_member_group($member_info['id'], $member_info['mg_type_expired'])) {
                    $member_info['mg_type']                  = $CONFIG['default_group_member'];
                    $member_info['mg_type_expired']  = 0;
                    $this_member_group = $sys->return_member_group($member_info['mg_type'], $member_info['point'], "*");
                    $member_info['mg_id']                    = $this_member_group['mg_id'];
                    $member_info['mg_type']                  = $this_member_group['mg_type'];
                    $member_info['mg_point_begin']           = $this_member_group['mg_point_begin'];
                    $member_info['mg_point_end']             = $this_member_group['mg_point_end'];
                    $member_info['mg_ag_id']                 = $this_member_group['mg_ag_id'];
                    $member_info['mg_name']                  = $this_member_group['mg_name'];
                    $member_info['mg_brief']                 = $this_member_group['mg_brief'];
                    $member_info['mg_icon']                  = $this_member_group['mg_icon'];
                    $member_info['mg_privilege']             = unserialize($this_member_group['mg_privilege']);
                    $member_info['mg_fileallow']             = unserialize($this_member_group['mg_fileallow']);
                    $member_info['mg_if_enable']             = $this_member_group['mg_if_enable'];
                    $member_info['mg_rank']                  = $this_member_group['mg_rank'];
                }
            }
        }
    }
    if (!preg_match("/^[1-9][0-9]{0,10}$/", $member_info['id'])) {
        $sys->prompt("failed",$LANGUAGE['s']['member_view']['member_not_exists']."<!-- member_not_exists -->");
    } else {
        $t->assign(array(
            "member_info"     => $member_info,
        ));
    }
}
$public_var['page_place'][] = $LANGUAGE['s']['member_view']['page_place'];
$public_var['page_place'][] = $member_info['username'];
?>
